<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>示例5</title>
    <script>
        for (let index of ['张三', '李四'].keys()) {
            console.log("index ---> ", index); // 输出下标 
        }
        for (let item of ['张三', '李四'].values()) {
            console.log("item ---> ", item); // 输出元素 
        }
        for (let entry of ['张三', '李四'].entries()) {
            console.log("entry ---> ", entry); //数组，第一个元素是下标，第二个元素是元素值 
        }
        // 我们可以用解构直接获取下标和元素值，推荐用法 
        for (let [index, elem] of ['张三', '李四'].entries()) {
            console.log(index, elem); // 输出下标和元素 
        }
    </script>
</head>
<body></body>

</html>